package com.learning.json;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.entity.EntityTemplate;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.json.JSONArray;
import org.json.JSONObject;

public class JSonParser4 {
	public static void main(String[] args) {
		try {
			String path = "http://appapi.very-news.com/moreNews.m?pull_type=down&channel=entertainment&sort_time=0&version_name=1.2.1&start_count=1&udid=E6BA61777016BE968AEFEA9FB9A065EB&uid=";
			HttpClient client = new DefaultHttpClient();
			HttpGet get = new HttpGet(path);
			HttpResponse response = client.execute(get);
			// String source="";
			// p(response.getStatusLine().getStatusCode());
			// p(EntityUtils.toString(response.getEntity()));
			JSONObject object = new JSONObject(EntityUtils.toString(response
					.getEntity()));
			p(object.get("channel_sequence"));
			JSONArray arr1 = object.getJSONArray("news");
			p(arr1.get(0));
			for (int j = 1; j < arr1.length(); j++) {
				JSONObject obj1 = arr1.getJSONObject(j);
				JSONArray arr2 = obj1.getJSONArray("thumbs");
				for (int i = 0; i < arr2.length(); i++) {
					p(arr2.get(i));
				}
			}
			// p(object);
		} catch (Exception e) {
		}

	}

	static void p(Object o) {
		System.out.println(o);
	}
}
